﻿using FluentMigrator;
using Infrastructure.Persistence;
using Infrastructure.Tenant;

namespace Infrastructure.Migrations.Tenants;

[Migration(202508181449)]
public class CreateTableForTenant : ForwardOnlyMigration
{
    public override void Up()
    {
        Create.Schema(SchemaNames.Tenant);

        Create
          .Table("Tenants")
          .InSchema(SchemaNames.Tenant)
          .WithColumn(nameof(BoilerplateTenantInfo.Id)).AsString(256).PrimaryKey().WithColumnDescription("主键")
          .WithColumn(nameof(BoilerplateTenantInfo.Identifier)).AsString(256).WithColumnDescription("标识符")
          .WithColumn(nameof(BoilerplateTenantInfo.Name)).AsString(256).WithColumnDescription("名称")
          .WithColumn(nameof(BoilerplateTenantInfo.ConnectionString)).AsString(1000).WithColumnDescription("数据库连接字符串")
          .WithColumn(nameof(BoilerplateTenantInfo.AdminEmail)).AsString(100).WithColumnDescription("邮箱地址/租户登录账号")
          .WithColumn(nameof(BoilerplateTenantInfo.IsActive)).AsBoolean().WithDefaultValue(false).WithColumnDescription("是否激活")
          .WithColumn(nameof(BoilerplateTenantInfo.ValidUpto)).AsDateTimeOffset().WithColumnDescription("有效日期")
          .WithColumn(nameof(BoilerplateTenantInfo.Issuer)).AsString(256).Nullable().WithColumnDescription("发行人");
    }
}
